<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>吉车惠后台管理系统</title>
    <%@include file="/global/global-other.jsp" %>

    <script type="text/javascript">
        var $bn_advertisement_issue_list = new Object();
        var $bn_advertisement_issue_list_Datagrid;
        var $bn_advertisement_issue_list_toolbar = [{
                text:'<i class="fa fa-search" aria-hidden="true"></i>刷新',
                handler:function(){
                    $bn_advertisement_issue_list.reload();
                }
            },{
                text:'<i class="fa fa-cloud-upload" aria-hidden="true"></i>发布',
                handler:function(){
                    $bn_advertisement_issue_list.saveInit();
                }
            },
            {
                text:'<i class="fa fa-edit" aria-hidden="true"></i>编辑',
                handler:function(){
                    $bn_advertisement_issue_list.updateInit();
                }
            },
            {
                text:'<i class="fa fa-trash-o" aria-hidden="true"></i>删除',
                handler:function(){
                    $bn_advertisement_issue_list.delete();
                }
            },'-',
            {
                text:'<i class="fa fa-arrow-circle-o-up" aria-hidden="true"></i>上架',
                handler:function(){
                    $bn_advertisement_issue_list.adup();
                }
            },
            {
                text:'<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>下架',
                handler:function(){
                    $bn_advertisement_issue_list.addown();
                }
            }
        ];
        $(function(){
            //gird 初始化
            $bn_advertisement_issue_list_Datagrid = $('#bn_advertisement_issue_list_Datagrid').datagrid({
                filterBtnIconCls:'icon-filter',
                queryParams: {
                    "filter_EQ_delete_status" : 0,
                    "filter_IN_putaway_status" : "0,1"
                },
                pageSize : 20,
                remoteFilter:true
            });

            $bn_advertisement_issue_list_Datagrid.datagrid('enableFilter', [
                {
                    field:'putawayStatus',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        data:json_sjzt
                    },
                    op:['equal']
                },
                {
                    field:'isPermanent',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        data:json_sfyj
                    },
                    op:['equal']
                },
                {
                    field:'mediaClassify',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        data:json_mtfl
                    },
                    op:['equal']
                },
                {
                    field:'beginDate',
                    type:'datebox',
                    op:['equal','greaterorequal','lessorequal']
                },
                {
                    field:'endDate',
                    type:'datebox',
                    op:['equal','greaterorequal','lessorequal']
                },
                {
                    field:'page',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        url:'${ctx}/tcode/all/method?method=getCacheCdAdvertisementPage'
                    },
                    op:['equal']
                },
                {
                    field:'adPositionid',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        url:'${ctx}/tcode/all/method?method=getCacheCdAdPosition'
                    },
                    op:['equal']
                },
                {
                    field:'adType',
                    type:'combobox',
                    options:{
                        valueField: 'code',
                        textField: 'name',
                        url:'${ctx}/tcode/all/method?method=getCacheCdAdType'
                    },
                    op:['equal']
                },
                {field:'seq',type:'label'},
                {field:'deviceSystem',type:'label'},
                {field:'pic',type:'label'},
                {field:'url',type:'label'},
                {field:'showWay',type:'label'},
                {field:'putawayAt',type:'label'},
                {field:'putawayBy',type:'label'},
                {field:'createAt',type:'label'},
                {field:'t',type:'label'}
            ]);

        });

        //刷新

        $bn_advertisement_issue_list.reload = function(){
            $bn_advertisement_issue_list_Datagrid.datagrid('reload');
        };

        var viewDialog ;
        //添加
        $bn_advertisement_issue_list.saveInit = function(){
            viewDialog = parent.$.dialog({
                title: '<i class="fa fa-th-large"></i><span class="dialog-title">&nbsp;广告发行<span>',
                href: '${ctx}/bn/advertisement/issue/up/insert?_m=init&r='+Math.random(),
                width: 800,
                height: 500,
                modal: true,
                onClose : function() {
                    $(this).dialog('destroy');
                },
                buttons: [{
                    text:'<i class="fa fa-floppy-o" aria-hidden="true"></i>&nbsp;保 存',
                    width:'70px',
                    handler: function(){
                        viewDialog.find('iframe').get(0).contentWindow.submitForm(viewDialog, $bn_advertisement_issue_list_Datagrid);
                    }
                },{
                    text:'<i class="fa fa-reply" aria-hidden="true"></i>&nbsp;返 回',
                    width:'70px',
                    handler: function(){
                        viewDialog.dialog('destroy');
                    }
                }]
            });
        }

        //编辑
        $bn_advertisement_issue_list.updateInit = function (){
            var row = $bn_advertisement_issue_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else if(row.putawayStatus=="1"){
                parent.$.messager.alert("提示",errMsg("已上架，不能进行编辑！"),"error");
            }else if(row.putawayStatus=="2"){
                parent.$.messager.alert("提示",errMsg("已下架，不能进行编辑！"),"error");
            }else{
                viewDialog = parent.$.dialog({
                    title: '<i class="fa fa-th-large"></i><span class="dialog-title">&nbsp;广告发行编辑<span>',
                    href: '${ctx}/bn/advertisement/issue/up/update?_m=init&id='+row.id+'&r='+Math.random(),
                    width: 800,
                    height: 500,
                    modal: true,
                    onClose : function() {
                        $(this).dialog('destroy');
                    },
                    buttons:[{
                        text:'<i class="fa fa-floppy-o" aria-hidden="true"></i>保存',
                        width:'70px',
                        handler:function(){
                            viewDialog.find('iframe').get(0).contentWindow.submitForm(viewDialog, $bn_advertisement_issue_list_Datagrid);
                        }
                    },{
                        text:'<i class="fa fa-reply" aria-hidden="true"></i>返回',
                        width:'70px',
                        handler:function(){
                            viewDialog.dialog('destroy');
                        }
                    }]
                });
            }
        }

        //删除
        $bn_advertisement_issue_list.delete = function (){
            var row = $bn_advertisement_issue_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else if(row.putawayStatus=="1"){
                parent.$.messager.alert("提示",errMsg("已上架，不能进行删除！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要删除广告全称【'+row.adName+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/bn/advertisement/issue/up/delete?_m=exec', {id : row.id}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","删除成功！","info",function(){
                                    $bn_advertisement_issue_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }

        //上架
        $bn_advertisement_issue_list.adup = function (){
            var row = $bn_advertisement_issue_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else if(row.putawayStatus=="1"){
                parent.$.messager.alert("提示",errMsg("已上架，不能重复操作！"),"error");
            }else if(row.putawayStatus=="2"){
                parent.$.messager.alert("提示",errMsg("已下架，不能上架！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要上架广告全称【'+row.adName+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/bn/advertisement/issue/up/adup?_m=exec', {id : row.id}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","上架成功！","info",function(){
                                    $bn_advertisement_issue_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }

        //下架
        $bn_advertisement_issue_list.addown = function (){
            var row = $bn_advertisement_issue_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else if(row.putawayStatus=="2"){
                parent.$.messager.alert("提示",errMsg("已下架，不能重复操作！"),"error");
            }else if(row.putawayStatus=="0"){
                parent.$.messager.alert("提示",errMsg("未上架，不能下架！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要下架广告全称【'+row.adName+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/bn/advertisement/issue/up/addown?_m=exec', {id : row.id}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","下架成功！","info",function(){
                                    $bn_advertisement_issue_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }

    </script>
</head>
<body>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:false">
        <table id="bn_advertisement_issue_list_Datagrid"  style="width:100%;height:100%"
               data-options="border:false,rownumbers:true,autoRowHeight:false,singleSelect:true,pagination:true,sortName:'createAt',sortOrder:'desc',toolbar:$bn_advertisement_issue_list_toolbar,rowStyler: function(index,row){return {style:'height:30px'};},url:'${ctx}/bn/advertisement/issue/up/search?_m=load',method:'post'">
            <thead>
            <tr>
                <th data-options="field:'adName',width:200,align:'center'">广告全称</th>
                <th data-options="field:'adShortName',width:150,align:'center'">广告简称</th>
                <th data-options="field:'pic',width:100,align:'center',formatter:
                    function(value,row,index){
                        if(row.pic==''||row.pic==undefined){
                            return '无';
                        }
                        return '<a href=\''+row.pic+'\' target=\'_blank\'>图片</a>'
                    }
                ">图片</th>
                <th data-options="field:'url',width:100,align:'center',formatter:
                    function(value,row,index){
                        if(row.url==''||row.url==undefined){
                            return '无';
                        }
                        return '<a href=\''+row.url+'\' target=\'_blank\'>地址</a>'
                    }
                ">访问地址</th>
                <th data-options="field:'putawayStatus',width:120,align:'center',formatter:
                    function(value,row,index){
                       if(row.putawayStatus=='0'){
                           return '未上架';
                       }else if(row.putawayStatus=='1'){
                            return '已上架';
                       }
                    }
                ">上架状态</th>
                <th data-options="field:'seq',width:80,align:'center'">排序</th>
                <th data-options="field:'isPermanent',width:120,align:'center',formatter:
                    function(value,row,index){
                       if(row.isPermanent=='1'){
                           return '永久';
                       }else if(row.isPermanent=='2'){
                            return '非永久';
                       }
                    }
                ">是否永久</th>
                <th data-options="field:'beginDate',width:150,align:'center'">开始日期</th>
                <th data-options="field:'endDate',width:150,align:'center'">结束日期</th>
                <th data-options="field:'mediaClassify',width:160,align:'center',formatter:
                    function(value,row,index){
                       if(row.mediaClassify=='1'){
                           return 'app：移动应用';
                       }else if(row.mediaClassify=='2'){
                            return 'pc：电脑';
                       }
                    }
                ">媒体分类</th>
                <th data-options="field:'page',width:140,align:'center',formatter:
                    function(value,row,index){
                       return row.pageName;
                    }
                ">页面</th>
                <th data-options="field:'adPositionid',width:160,align:'center',formatter:
                    function(value,row,index){
                       return row.adPositionidName;
                    }
                ">广告位</th>
                <th data-options="field:'adType',width:110,align:'center',formatter:
                    function(value,row,index){
                       return row.adTypeName;
                    }
                ">广告类型</th>
                <th data-options="field:'deviceSystem',width:100,align:'center',formatter:
                    function(value,row,index){
                       if(row.deviceSystem=='1'){
                           return '苹果(ios)';
                       }else if(row.deviceSystem=='2'){
                            return '安卓(android)';
                       }else if(row.deviceSystem=='3'){
                            return '全部';
                       }
                    }
                ">设备系统</th>
                <th data-options="field:'showWay',width:80,align:'center',formatter:
                    function(value,row,index){
                       if(row.showWay=='1'){
                           return '轮播';
                       }else if(row.showWay=='2'){
                            return '静态';
                       }else if(row.showWay=='3'){
                            return '动态';
                       }else if(row.showWay=='4'){
                            return '列表';
                       }
                    }
                ">展示方式</th>
                <th data-options="field:'putawayAt',width:150,align:'center'">上架时间</th>
                <th data-options="field:'putawayBy',width:80,align:'center'">上架人</th>
                <th data-options="field:'createAt',width:150,align:'center'">添加时间</th>
                <th data-options="field:'t',width:20,align:'center'"></th>
            </tr>
            </thead>
        </table>
    </div>
</div>
</body>
</html>